"""
Case Type   : 功能测试
Case Name   : gs_ddr工具搭建存储双集群语法错误
Create At   : 2025/03/25
Owner       : @chen
Description :
    1.gs_ddr -t start
    2.gs_ddr -t start -m primary
Expect      :
    1.合理报错
    2.合理报错
History     :
"""

import unittest
import os
from testcase.utils.Logger import Logger
from yat.test import Node
from yat.test import macro
logger = Logger()

class Dual_Cluster_Redution_Case0002(unittest.TestCase):
    def setUp(self):
        logger.info(f'--------{os.path.basename(__file__)} start--------')
        self.pri_node = Node('P_PrimaryDbUser')

    def test_shared_storage(self):
        opt = ['gs_ddr -t start', 'gs_ddr -t start -m primary']
        for cmd in opt:
            logger.info(f'-----{cmd} expect:合理报错-----')
            check_cmd = f'source {macro.DB_ENV_PATH}; {cmd}'
            logger.info(check_cmd)
            res = self.pri_node.sh(check_cmd).result()
            self.assertIn(r'Failed to check -X parameter. XML file ' \
                r'and json file are all not exist.', res, 
                f'{check_cmd} 命令校验失败')

    def tearDown(self):
        logger.info(f'-----{os.path.basename(__file__)} end-----')
